﻿using Dal;
using Model;

namespace Bll
{
    public class memberBll
    {
        private readonly memberDal dal;

        public memberBll(memberDal dal)
        {
            this.dal = dal;
        }

        /// <summary>
        /// 会员信息录入
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int PostMemberAdd(T_MemberInfo info)
        {
            try
            {
                int res = dal.SearchPhone(info.M_Phone);
                if(res > 0)
                {
                    return -1;
                }
                else
                {
                    int list = dal.PostMemberAdd(info);
                    if(list > 0)
                    {
                        return 1;
                    }
                    else
                    {
                        return -2;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 查询数据显示
        /// </summary>
        /// <param name="name">会员姓名</param>
        /// <param name="phone">手机号</param>
        /// <param name="card">身份证号</param>
        /// <param name="code">卡号</param>
        /// <param name="createDate">创建时间</param>
        /// <returns></returns>
        public List<T_MemberInfo> GetMemberList(string? name, string? phone, string? card, string? code, DateTime createDate)
        {
            try
            {
               return dal.GetMemberList(name, phone, card, code, createDate);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}